package com.heima.utils.thread;

import com.heima.model.admin.pojos.AdUser;

/**
 * @Author: xrl
 * @Date: 2022/10/22  10:10
 * @Version 1.0
 */
public class AdThreadLocalUtil {
    private final static ThreadLocal<AdUser> AD_USER_THREAD_LOCAL = new ThreadLocal<>();

    /**
     * 添加到线程
     */
    public static void setUser(AdUser adUser) {
        AD_USER_THREAD_LOCAL.set(adUser);
    }


    /**
     * 从线程中获取
     */
    public static AdUser getUser() {
        return AD_USER_THREAD_LOCAL.get();
    }

    /**
     * 从线程中清理
     */
    public static  void  delete() {
        AD_USER_THREAD_LOCAL.remove();
    }
}
